package logic

import (
	"context"
	"poblish_house/house_srv/house"

	"poblish_house/api/internal/svc"
	"poblish_house/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type SendSmsRequestLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSendSmsRequestLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsRequestLogic {
	return &SendSmsRequestLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SendSmsRequestLogic) SendSmsRequest(req *types.SendSmsRequest) (resp *types.Response, err error) {
	_, err = l.svcCtx.HouseSrv.SendSmsCode(l.ctx, &house.SendSmsCodeRequest{
		Mobile: req.Mobile,
		Code:   req.Code,
	})
	if err != nil {
		return &types.Response{
			Code: -1,
			Msg:  "登录失败",
			Data: nil,
		}, nil
	}

	return &types.Response{
		Code: -1,
		Msg:  "登录成功",
		Data: nil,
	}, nil
	if req.Mobile != req.Mobile {
		return &types.Response{
			Code: -2,
			Msg:  "不存在",
			Data: nil,
		}, nil
	}
	return
}
